﻿#region Using

using System;
using System.IO;
using System.Text;
using System.Xml.Serialization;

#endregion

namespace WSMon.Core.Helpers
{
    public abstract class XmlFactory
    {
        public static void WriteToXml(string path, Type type, Object obj)
        {
            var s = new XmlSerializer(type);
            var w = new StreamWriter(path, false, Encoding.UTF8);
            s.Serialize(w, obj);
            w.Close();
        }

        public static object ReadFromXml(string path, Type type)
        {
            var s = new XmlSerializer(type);
            var r = new StreamReader(path);
            object obj = s.Deserialize(r);
            r.Close();

            return obj;
        }
    }
}